package com.itheima.web.controller;

import com.itheima.domain.system.User;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    protected HttpServletRequest request;
    protected HttpServletResponse response;
    HttpSession session;
    protected String companyId;
    protected String companyName;
    protected User loginUser;

    @ModelAttribute
    public void init(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        this.request = request;
        this.response = response;
        this.session = session;

        User user = (User) session.getAttribute("loginUser");
        if (user != null) {
            this.loginUser = user;
            companyId = user.getCompanyId();
            companyName = user.getCompanyName();
        }

        /*companyId = "1";
        companyName = "传智播客教育股份有限公司";*/
    }
}
